﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using System.IO;
using ExamAnalysis.Core;
using ExamAnalysis.Model;
using System.Web.Security;

namespace ExamAnalysis
{
    public partial class Desktop : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !X.IsAjaxRequest)
            {
                if (!IsPostBack && !X.IsAjaxRequest)
                {
                    ShowMenu();
                }
            }
        }

        private void ShowMenu()
        {
            string[] roles = Roles.GetRolesForUser();


            Desktop1.Modules[1].Shortcut.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 2);
            Desktop1.Modules[1].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 2);

            Desktop1.Modules[2].Shortcut.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 3);
            Desktop1.Modules[2].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 3);

            Desktop1.Modules[3].Shortcut.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 4);
            Desktop1.Modules[3].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 4);

            Desktop1.Modules[4].Shortcut.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 5);
            Desktop1.Modules[4].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 5);


            Desktop1.Modules[7].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 6);


            Desktop1.Modules[5].Shortcut.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 7);
            Desktop1.Modules[5].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 7);

            Desktop1.Modules[6].Shortcut.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 9);
            Desktop1.Modules[6].Launcher.Hidden = !Core.Rights.HasMenuRightByRoles(roles, 9);
        }

        protected void Logout_Click(object sender, DirectEventArgs e)
        {
            // Logout from Authenticated Session
            System.Web.Security.FormsAuthentication.SignOut();
            //返回到登录页面 
            this.Response.Redirect(System.Web.Security.FormsAuthentication.LoginUrl); 
        }
    }
}